<template>
    <div class="widget-logistic" v-loading="loading">
        <el-timeline :reverse="true" v-if="list.length > 0">
            <el-timeline-item v-for="(item, index) in list" :key="index" :timestamp="item.status + ' ' + item.time" placement="top" :type="index === list.length - 1 ? 'success' : ''">
                {{ item.context }}
            </el-timeline-item>
        </el-timeline>
        <el-empty description="暂无物流信息" v-else></el-empty>
    </div>
</template>

<script>
import { getOrderProgressByCourierNumber } from '@/api/workOrder'

export default {
    props: {
        id: {
            type: [String, Number],
            default: null
        }
    },
    data() {
        return {
            // 物流进度
            list: [],
            // 加载
            loading: false
        };
    },
    methods: {
        // 初始物流进度
        initLogistic() {
            this.loading = true
            getOrderProgressByCourierNumber(this.id).then(res => {
                this.list = res && res.data && res.data.data ? res.data.data : []
                this.loading = false
            }).catch(error => {
                this.loading = false
            })
        },
    },
    mounted() {

    },
};
</script>

<style lang="scss" scoped>
.widget-logistic {
    min-height: 300px;
    max-height: 500px;
    overflow: hidden scroll;
}
</style>